{extend name="public/basic"}
{block name="main"}
<h1 style = "margin-top:16px;">实名认证信息</h1>
<hr />
{if condition="isset($cert) and $cert.valid neq 2"}
    <div class = "layui-form">
        {if condition="$cert.valid eq 1"}
        <p class = "vm-3 b fs-1 ">实名认证已通过审核</p>
        {else/}
        <p class = "vm-3 b fs-1 warning">实名认证已提交审核，工作人员将在2-3个工作日审核...</p>
        {/if}
        <div class = "layui-form-item">
            <label class = "layui-form-label">正面照</label>
            <div class = "layui-input-block">
                <img src = "{$cert.front|default='/static/images/cert1.jpg'}" class = "cert-image"/>
            </div>
        </div>
        <div class = "layui-form-item">
            <label class = "layui-form-label">反面照</label>
            <div class = "layui-input-block">
                <img src = "{$cert.behind|default='/static/images/cert2.jpg'}" class = "cert-image"/>
            </div>
        </div>
        <div class = "layui-form-item">
            <label class = "layui-form-label">手持正面照</label>
            <div class = "layui-input-block">
                <img src = "{$cert.person|default='/static/images/cert3.jpg'}" class = "cert-image"/>
            </div>
        </div>
    </div>
{else/}
    {if condition="isset($cert) and $cert.valid eq 2"}
        <p class = "vm-3 b fs-1 danger">实名审核不通过，原因：{$cert.audit_text|default=''}</p>
    {/if}
    <form class = "layui-form ajax _form" action="{:url('edit_cert')}" method="post">
        <div class = "layui-form-item">
            <label class = "layui-form-label">正面照</label>
            <div class = "layui-input-block">
                <input type="hidden" value="{$cert.front|default=''}" name="front" id = "front"/>
                <img src = "{$cert.front|default='/static/images/cert1.jpg'}" class = "cert-image" id = "img-front"/>
            </div>
        </div>
        <div class = "layui-form-item">
            <label class = "layui-form-label">反面照</label>
            <div class = "layui-input-block">
                <input type="hidden" value="{$cert.behind|default=''}" name="behind" id = "behind"/>
                <img src = "{$cert.behind|default='/static/images/cert2.jpg'}" class = "cert-image" id = "img-behind"/>
            </div>
        </div>
        <div class = "layui-form-item">
            <label class = "layui-form-label">手持正面照</label>
            <div class = "layui-input-block">
                <input type="hidden" value="{$cert.person|default=''}" name="person" id = "person"/>
                <img src = "{$cert.person|default='/static/images/cert3.jpg'}" class = "cert-image" id = "img-person"/>
            </div>
        </div>
        <div class = "layui-form-item">
            <button class = "fr layui-btn layui-btn-success">提交</button>
        </div>
    </form>
{/if}
{/block}
{block name="script"}
    layui.use(["upload","layer","form"],function(){
        var upload = layui.upload;
        var layer = layui.layer;
        var form = layui.form;
        var cert1Inst = upload.render({
            elem:"#img-front",
            url:"{:url('home/file/upload')}",
            done: function(res) {
                $("#img-front").attr("src",res.msg);
                $("#front").val(res.msg);
            },
            error:function() {
                layer.msg('上传失败');
            }
        })
        var cert2Inst = upload.render({
            elem:"#img-behind",
            url:"{:url('home/file/upload')}",
            done:function(res){
                $("#img-behind").attr("src",res.msg);
                $("#behind").val(res.msg);
            },
            error:function() {
                layer.msg("上传失败");
            }
        })
        var cert3Inst = upload.render({
            elem:"#img-person",
            url:"{:url('home/file/upload')}",
            done:function(res){
                $("#img-person").attr("src",res.msg);
                $("#person").val(res.msg);
            },
            error:function() {
                layer.msg("上传失败");
            }
        });
    });
{/block}